﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SHKF.B2C.BaseHosted
{
    /// <summary>
    /// 基础控制器
    /// </summary>
    [Route("[controller]")]
    [ApiController]
    public class BaseController : ControllerBase
    {
        protected readonly ILogger<BaseController> logger;
        protected const string TraceId = "TraceId";

        public BaseController(ILogger<BaseController> logger)
        {
            this.logger = logger;
        }

        protected void WriteException(string fun, Exception ex)
        {
            if (this.logger != null)
            {
                this.logger.LogError($"fun:{fun}>> ex:{ex.Message}");
            }

        }

        protected void WriteInformation(string fun, string msg)
        {
            if (this.logger != null)
            {
                this.logger.LogInformation($"fun:{fun}>> msg:{msg}");
            }
        }

    }
}
